home *** CD-ROM | disk | FTP | other *** search
Wrap
(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=nono.1 Title=CinΘstore Description=CinΘstore (FR) import avec Affiche Site=http://www.cinestore.com Language=FR Version=26/11/2002 Requires=3.5.0 Comments=crΘation le 21/08/2002 par nono.1| modifiΘ le 17/09/2002 par nono.1| modifiΘ le 14/11/2002 par nono.1| modifiΘ le 26/11/2002 par nono.1| License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | GetInfo=1 [Options] ***************************************************) program Cinestore; var MovieName: string; function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer; var i: Integer; begin result := -1; if StartAt < 0 then StartAt := 0; for i := StartAt to List.Count-1 do if Pos(Pattern, List.GetString(i)) <> 0 then begin result := i; Break; end; end; procedure AnalyzePage(Address: string); var Page: TStringList; LineNr: Integer; begin Page := TStringList.Create; Page.Text := GetPage(Address); if pos('réponses α votre recherche', Page.Text) = 0 then begin SetField(fieldURL, Address); AnalyzeMoviePage(Page); end else begin PickTreeClear; LineNr := 0; LineNr := FindLine('href="fiche_produits.php?groupe=1&page=1&id=', Page, LineNr); if LineNr > -1 then begin PickTreeAdd('Films prΘsents', ''); AddMoviesTitles(Page, LineNr); end; if PickTreeExec(Address) then AnalyzePage(Address); end; Page.Free; end; procedure AnalyzeMoviePage(Page: TStringList); var Line, Value,FullValue : string; LineNr, IntValue: Integer; BeginPos, EndPos: Integer; begin // Picture LineNr := FindLine('<img src="http://a333.g.akamai.net/f/333/6918/3h/img.cinestore.com/photo/puce/', Page, 0); if LineNr > -1 then begin Line := Page.GetString(LineNr); BeginPos := pos('src="', Line)+5; EndPos := pos('" width="50" height="70" class="aimg" border="1"', Line); Value := copy(Line, BeginPos, EndPos - BeginPos); GetPicture(Value); end // Translated Title LineNr := FindLine('<b>Titre Franτais:</b>', Page, 0); if LineNr > -1 then begin Line := Page.GetString(LineNr+1); BeginPos := pos('<font color="#000000">', Line); EndPos := pos('</font>', Line); Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(fieldTranslatedTitle, Value); end; // Original Title LineNr := FindLine('<b>Titre Original:</b>', Page, 0); if LineNr > -1 then begin Line := Page.GetString(LineNr+1); BeginPos := pos('<font color="#000000">', Line); EndPos := pos('</font>', Line); Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(fieldOriginalTitle, Value); end; // Description LineNr := FindLine('histoire :</b>', Page, LineNr); if LineNr > -1 then begin Line := Page.GetString(LineNr+1); BeginPos := pos('<font color="#000000">', Line); EndPos := pos('</font>', Line); Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(fieldDescription, Value); end; // Category LineNr := FindLine('src="http://a333.g.akamai.net/f/333/6918/3h/img.cinestore.com/images/t/theme_1.gif"', Page, 0); if LineNr > -1 then begin repeat LineNr := LineNr+1; Line := Page.GetString(LineNr); until pos('</tr>', Line) > 0; Line := Page.GetString(LineNr+2); BeginPos := pos('color="#000000">', Line)+16; EndPos := pos('</font></td>', Line); Value := copy(Line, BeginPos, EndPos - BeginPos); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(fieldCategory, Value); end; // Length LineNr := FindLine('<B>DurΘe:</b>', Page, 0); if LineNr > -1 then begin Line := Page.GetString(LineNr+1); BeginPos := pos('<font color="#000000">', Line); EndPos := pos(' mn</font>', Line); Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(fieldLength, Value); end; // Actors LineNr := FindLine('<b>Acteurs(s) :</b>', Page, 0); if LineNr > -1 then begin FullValue := ''; Line := Page.GetString(LineNr); repeat BeginPos := pos('scrollbars=yes,top=0,left=0,width=330,height=400', Line); Delete(Line, 1, BeginPos+51); EndPos := pos('</a>', Line); Value := copy(Line, 1, EndPos - 1); Delete(Line, 1, EndPos+3); if FullValue <> '' then FullValue := FullValue + ', '; FullValue := FullValue + Value; until pos(' . </font>',Line) = 1; HTMLRemoveTags(FullValue); HTMLDecode(FullValue); SetField(fieldActors, FullValue); end; // Director LineNr := FindLine('<b>RΘalisateur(s) :</b>', Page, 0); if LineNr > -1 then begin FullValue := ''; Line := Page.GetString(LineNr); Delete(Line, 1, pos('<b>RΘalisateur(s) :</b>',Line)); repeat BeginPos:= pos('scrollbars=yes,top=0,left=0,width=330,height=400',Line); Delete(Line, 1, BeginPos+51); EndPos := pos('</a>', Line); Value := copy(Line, 1, EndPos - 1); Delete(Line, 1, EndPos+3); if FullValue <> '' then FullValue := FullValue + ', '; FullValue := FullValue + Value; until pos(' . </font>',Line) = 1; HTMLRemoveTags(FullValue); HTMLDecode(FullValue); SetField(fieldDirector, FullValue); end; // Year LineNr := FindLine('<B>Date de sortie du film :</b>', Page, 0); if LineNr > -1 then begin Line := Page.GetString(LineNr+1); BeginPos := pos('</font>', Line); Value := copy(Line, BeginPos - 4, 4); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(fieldYear, Value); end; // Commentaires LineNr := FindLine('<B>Public :</b>', Page, 0); if LineNr > -1 then begin Line := Page.GetString(LineNr+1); BeginPos := pos('<font color="#000000">', Line); EndPos := pos('</font>', Line); Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22); HTMLRemoveTags(Value); HTMLDecode(Value); SetField(fieldComments, Value); end; //DisplayResults; end; procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer); var MovieProduct,MovieTitle, MovieAddress, Line, LineProduct: string; StartPos, EndPos, LineNRProduct: Integer; begin LineNr := LineNr - 1; repeat LineNr := LineNr + 1; LineNRProduct := LineNr; Line := Page.GetString(LineNr); StartPos := pos('size="1" color="#3C1A36"><b>', Line); if StartPos > 0 then begin Delete(Line, 1, StartPos); StartPos := pos('href="fiche_produits.php?groupe=1', Line); Delete(Line, 1, StartPos); EndPos := pos('"><font color="#3C1A36">',Line); MovieAddress := copy(Line, 44, EndPos -44); Delete(Line, 1, EndPos); MovieTitle := copy(Line, 24, pos('</font></a>', Line)-24); HTMLRemoveTags(MovieTitle); HTMLDecode(MovieTitle); repeat LineNRProduct := LineNRProduct+1; LineProduct := Page.GetString(LineNRProduct); until (pos('<font color="#3C1A36"><b>de</b>', LineProduct) > 0) or (pos('images/i/invisible.gif" width="60%" height="1" border="0"><img',LineProduct) > 0); if pos('images/i/invisible.gif" width="60%" height="1" border="0"><img',LineProduct) > 0 then begin MovieProduct := ''; end else begin StartPos := pos('left=0,width=330,height=400',LineProduct); Delete(LineProduct,1,StartPos+30); MovieProduct :=copy(LineProduct, 1,pos('</a></font>',LineProduct)-1); HTMLRemoveTags(MovieProduct); HTMLDecode(MovieProduct); MovieProduct := ' (de ' + MovieProduct + ')'; end; PickTreeAdd(MovieTitle+MovieProduct, 'http://www.cinestore.com/html/fiche_produits.php?groupe=1&page=2&id='+MovieAddress); end; until pos('<font color="#3C1A36">[1]</font>', Line) > 0; end; begin if CheckVersion(3,5,0) then begin MovieName := GetField(fieldTranslatedTitle); if MovieName = '' then MovieName := GetField(fieldOriginalTitle); if Input('Importation de CinΘstore.com', 'Entrer le titre du film:', MovieName) then begin AnalyzePage('http://www.cinestore.com/html/liste_mixte.php?CINESTORE=1a5694f56f546666f7761a537b867798&recstr='+UrlEncode(MovieName)+'&grprec=1&type=recherche&id_partenaire=1&x=7&y=8'); end; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.